package com.chenglu.android.order;

import android.content.Context;
import android.icu.text.CaseMap;
import android.text.InputType;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.chenglu.android.R;
import com.chenglu.android.common.net.Constant;
import com.chenglu.android.common.utils.LogUtils;

/**
 * @author: lyj
 * @Created: by Copyright 2023/10/30 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：
 */
public class TextStatusUtils {

//    case none = 0                /// 空
//    case shop = 1                /// 商超
//    case restaurant = 2          /// 餐饮
//    case beauty = 3              /// 美业
//    case education = 4           /// 教育
//    case minimart = 8            /// 便利店
//    case pharmaceuticals = 9     /// 药店
//    case breed = 10              /// 孕育
//    case max = 999               /// 平台公共


    //    /// 拓展状态 餐饮:1-商家制作中 2-待到店自取 3-待到店使用 4-待骑手接单 5-待骑手取货 6-骑手配送中 7-配送异常 9-骑手已送达
//    enum YMTakeawayExtStatus: Int, HandyJSONEnum {
//        case none = 0                         /// 无
//        case shopMaking = 1                   /// 商家制作中
//        case awaitUserReceive = 2             /// 待到店自取
//        case awaitUse = 3                     /// 待到店使用
//        case awaitDeliverymanTakeOrder = 4    /// 待骑手接单
//        case awaitDeliverymanTakeReceive = 5  /// 待骑手取货
//        case awaitDelivering = 6              /// 骑手配送中
//        case awaitDeliveryError = 7           /// 配送异常
//        case awaitDeliverySuccess = 9         /// 骑手已送达
//    }
    public static void setHeadText(int shopTypes, int status, int isUse, int extStatus, TextView textView) {
        if ((shopTypes == Constant.typeIdRestaurant || shopTypes == Constant.typeIdMinimart
                || shopTypes == Constant.typeIdPharmaceuticals || shopTypes == Constant.typeIdBreed) && (status == 2 || status == 3)) {

            switch (extStatus) {
                case 0:
                    textView.setText("");
                    break;
                case 1:
                    if (shopTypes == Constant.typeIdRestaurant) {
                        textView.setText("制作中");
                    } else {
                        textView.setText("商家配货中");
                    }

                    break;
                case 2:
                    textView.setText("待到店自取");
                    break;
                case 3:
                    textView.setText("待到店使用");
                    break;
                case 4:
                    textView.setText("待骑手接单");
                    break;
                case 5:
                    textView.setText("待骑手取货");
                    break;
                case 6:
                    textView.setText("骑手配送中");
                    break;

                case 7:
                    textView.setText("配送异常");
                    break;
                case 9:
                    textView.setText("骑手已送达");
                    break;
                default:
                    textView.setText("");
                    break;

            }

        } else {
            // 如果为美业或教育。“收货”改为“使用”
            if (shopTypes == Constant.typeIdBeauty || shopTypes == Constant.typeIdEducation) {
                isUse = 1;
            }

//           /// 商超订单状态 -2已退款 ,-1售后中 ,0、已取消 1、待支付 2、待发货 3、待收货 4、待评价 5、已评价
            switch (status) {
                case -2:
                    textView.setText("已退款");
                    break;

                case -1:
                    textView.setText("售后中");
                    break;
                case 0:
                    textView.setText("已取消");
                    break;
                case 1:
                    textView.setText("待支付");
                    break;
                case 2:
                    if (isUse == 1) {
                        textView.setText("待使用");
                    } else {
                        textView.setText("待发货");
                    }

                    break;
                case 3:
                    if (isUse == 1) {
                        textView.setText("待使用");
                    } else {
                        textView.setText("待收货");
                    }
                    break;
                case 4:
                    textView.setText("待评价");
                    break;
                case 5:
                    textView.setText("已评价");
                    break;

                default:
                    break;

            }

        }


    }


    public static void setOrderImageView(Context context,int shopTypes, int status, int isUse, int extStatus, String code,
                                         TextView tvdes, TextView tvcodeNum, TextView tvIsPickup,ImageView imageView) {
        if ((shopTypes == Constant.typeIdRestaurant || shopTypes == Constant.typeIdMinimart
                || shopTypes == Constant.typeIdPharmaceuticals || shopTypes == Constant.typeIdBreed) && (status == 2 || status == 3)) {

            switch (extStatus) {
                case 0:
                    tvdes.setText("");
                    break;
                case 1:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    if (shopTypes == Constant.typeIdRestaurant) {
                        tvdes.setText("制作中");
                    } else {
                        tvdes.setText("商家配货中");
                    }

                    break;
                case 2:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    tvdes.setText("待到店自取");
                    break;
                case 3:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    tvdes.setText("待到店使用");
                    break;
                case 4:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    tvdes.setText("待骑手接单");
                    break;
                case 5:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    tvdes.setText("待骑手取货");
                    break;
                case 6:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    tvdes.setText("骑手配送中");
                    break;

                case 7:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.VISIBLE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    tvdes.setText("配送异常");
                    break;
                case 9:
                    tvcodeNum.setText(code+"");
                    tvIsPickup.setVisibility(View.GONE);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_form_complete));
                    tvdes.setText("骑手已送达");
                    break;
                default:
                    tvdes.setText("");
                    break;

            }
            if(shopTypes==Constant.typeIdRestaurant ){
                tvIsPickup.setText("取餐码");
            }else {
                tvIsPickup.setText("取货码");
            }

        } else {
            // 如果为美业或教育。“收货”改为“使用”
            if (shopTypes == Constant.typeIdBeauty || shopTypes == Constant.typeIdEducation) {
                isUse = 1;
            }

//           /// 商超订单状态 -2已退款 ,-1售后中 ,0、已取消 1、待支付 2、待发货 3、待收货 4、待评价 5、已评价
            switch (status) {
                case -2:
                    tvcodeNum.setText("已退款");
                    tvdes.setText("");
                    break;

                case -1:
                    tvcodeNum.setText("售后中");
                    break;
                case 0:
                    tvcodeNum.setText("已取消");
                    tvdes.setText(R.string.orderinfo_wait_cancel);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_cancel));
                    break;
                case 1:
                    tvcodeNum.setText("待支付");
                    tvdes.setText(R.string.orderinfo_wait_pay);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_payment));
                    break;
                case 2:

                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_deliver_goods));
                    if (isUse == 1) {
                        tvcodeNum.setText("待使用");
                        tvdes.setText("使用前建议提前跟商家沟通");
                    } else {
                        tvcodeNum.setText("待发货");
                        tvdes.setText(R.string.orderinfo_wait_send_goods);
                    }

                    break;
                case 3:

                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_send_goods));
                    if (isUse == 1) {
                        tvcodeNum.setText("待使用");
                        tvdes.setText("使用前建议提前跟商家沟通");
                    } else {
                        tvcodeNum.setText("待收货");
                        tvdes.setText(R.string.orderinfo_wait_receive_goods);
                    }
                    break;
                case 4:
                    tvdes.setText(R.string.orderinfo_wait_comment);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_wait_review));
                    tvcodeNum.setText("待评价");
                    break;
                case 5:
                    tvdes.setText(R.string.orderinfo_wait_finish);
                    imageView.setBackground(context.getResources().getDrawable(R.drawable.order_form_complete));
                    tvcodeNum.setText("已评价");
                    break;

                default:
                    break;

            }

        }


    }

    //三个按钮的状态
    //btn3 为联系客服 其他不困定 看状态

//      <string name="order_contract_custom">联系客服</string>
//
//    <string name="order_look_logistics">查看物流</string>
//
//    <string name="order_cancel">取消订单</string>
//
//    <string name="order_delete">删除订单</string>
//
//    <string name="order_buy_again">再次购买</string>
//
//    <string name="order_confirm_receipt">确认收货</string>
//
//    <string name="order_comment_message">评价</string>
//
//    <string name="order_immediate_payment">立即支付</string>

//    商超订单状态 -2已退款 ,-1售后中 ,0、已取消 1、待支付 2、待发货 3、待收货 4、待评价 5、已评价

    public  static  void  setfooterBtn(Context context,int shopTypeId, int status, int extStatus,TextView btn1, TextView btn2, TextView btn3){
        if(shopTypeId==Constant.typeIdBeauty || shopTypeId == Constant.typeIdEducation){
            switch (status){
                    case -2:
                        break;
                    case -1:
                        break;
                    case 0:
                        btn1.setVisibility(View.VISIBLE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.GONE);
                        btn1.setText(context.getResources().getString(R.string.order_delete));
                        btn2.setText(context.getResources().getString(R.string.order_buy_again));
                        btn3.setText("");
                        break;
                    case 1:
                        btn1.setVisibility(View.VISIBLE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.GONE);
                        btn1.setText(context.getResources().getString(R.string.order_cancel));
                        btn2.setText(context.getResources().getString(R.string.order_immediate_payment));
                        btn3.setText("");
                        break;
                    case 2:
                        btn1.setVisibility(View.GONE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText("");
                        btn2.setText(context.getResources().getString(R.string.order_buy_again));
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                        break;
                    case 3:
                        LogUtils.e("走到这里3333待使用");
                        btn1.setVisibility(View.GONE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText("");
                        btn2.setText(context.getResources().getString(R.string.order_buy_again));
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                        break;
                    case 4:
                        btn1.setVisibility(View.VISIBLE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText(context.getResources().getString(R.string.order_comment_message));
                        btn2.setText(context.getResources().getString(R.string.order_buy_again));
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                        break;
                    case 5:
                        btn1.setVisibility(View.GONE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText("");
                        btn2.setText(context.getResources().getString(R.string.order_buy_again));
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                        break;
                    default:
                        break;

            }
        }else {

            switch (status){
                case -2:
                    break;
                case -1:
                    break;
                case 0:
                    btn1.setVisibility(View.VISIBLE);
                    btn2.setVisibility(View.VISIBLE);
                    btn3.setVisibility(View.GONE);
                    btn1.setText(context.getResources().getString(R.string.order_delete));
                    btn2.setText(context.getResources().getString(R.string.order_buy_again));
                    btn3.setText("");
                    break;
                case 1:
                    btn1.setVisibility(View.VISIBLE);
                    btn2.setVisibility(View.VISIBLE);
                    btn3.setVisibility(View.GONE);
                    btn1.setText(context.getResources().getString(R.string.order_cancel));
                    btn2.setText(context.getResources().getString(R.string.order_immediate_payment));
                    btn3.setText("");
                    break;
                case 2:
                    btn1.setVisibility(View.GONE);
                    btn2.setVisibility(View.GONE);
                    btn3.setVisibility(View.VISIBLE);
                    btn1.setText("");
                    btn2.setText(context.getResources().getString(R.string.order_buy_again));
                    btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                    break;
                case 3:
                    //        case none = 0                         /// 无
//        case shopMaking = 1                   /// 商家制作中
//        case awaitUserReceive = 2             /// 待到店自取
//        case awaitUse = 3                     /// 待到店使用
//        case awaitDeliverymanTakeOrder = 4    /// 待骑手接单
//        case awaitDeliverymanTakeReceive = 5  /// 待骑手取货
//        case awaitDelivering = 6              /// 骑手配送中
//        case awaitDeliveryError = 7           /// 配送异常
//        case awaitDeliverySuccess = 9         /// 骑手已送达
                    //待定

                    if((shopTypeId==Constant.typeIdRestaurant ||shopTypeId ==Constant.typeIdMinimart || shopTypeId ==Constant.typeIdPharmaceuticals || shopTypeId ==Constant.typeIdBreed)
                            && (extStatus!= 2 || extStatus!= 3 || extStatus!= 6 || extStatus!=9)){

                        btn1.setVisibility(View.GONE);
                        btn2.setVisibility(View.GONE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText("");
                        btn2.setText("");
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                    }else {
                        btn2.setVisibility(View.VISIBLE);
                        btn2.setText(context.getResources().getString(R.string.order_confirm_receipt));
                        btn3.setVisibility(View.VISIBLE);
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                        if(shopTypeId == Constant.typeIdShop){
                            btn1.setVisibility(View.VISIBLE);
                            btn1.setText(context.getResources().getString(R.string.order_look_logistics));
                        }

                    }

                    break;
                case 4:
                    if(shopTypeId==Constant.typeIdShop){
                        btn1.setVisibility(View.VISIBLE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText(context.getResources().getString(R.string.order_look_logistics));
                        btn2.setText(context.getResources().getString(R.string.order_comment_message));
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                    }else {
                        btn1.setVisibility(View.GONE);
                        btn2.setVisibility(View.VISIBLE);
                        btn3.setVisibility(View.VISIBLE);
                        btn1.setText(context.getResources().getString(R.string.order_look_logistics));
                        btn2.setText(context.getResources().getString(R.string.order_comment_message));
                        btn3.setText(context.getResources().getString(R.string.order_contract_custom));
                    }

                    break;
                case 5:
                    btn1.setVisibility(View.GONE);
                    btn2.setVisibility(View.VISIBLE);
                    btn3.setVisibility(View.GONE);
                    btn1.setText("");
                    btn2.setText(context.getResources().getString(R.string.order_buy_again));
                    btn3.setText("");
                    break;
                default:
                    btn1.setVisibility(View.GONE);
                    btn2.setVisibility(View.VISIBLE);
                    btn3.setVisibility(View.GONE);
                    btn2.setText(context.getResources().getString(R.string.order_buy_again));
                    break;

            }

        }

    }

    public   static  void  setBtn2Colors(Context context ,TextView btn2,int orderType){

        switch (orderType){
            case 1:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_shop_corner_shape_15));
                break;
            case 3:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_restaurant_corner_shape_15));
                break;
            case 4:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_education_corner_shape_15));
                break;
            case 5:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_minimart_corner_shape_15));
                break;
                case 6:
                    btn2.setBackground(context.getResources().getDrawable(R.drawable.order_beauty_corner_shape_15));
                break;
            case 7:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_pharmaceuticals_corner_shape_15));
                break;
            case 8:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_breed_corner_shape_15));
                break;
            default:
                btn2.setBackground(context.getResources().getDrawable(R.drawable.order_shop_corner_shape_15));
                break;

        }

    }



}
